<?php
// +----------------------------------------------------------------------
// | Azthink通用开发平台 [ TOMORROW IS ANOTHER DAY ]
// +----------------------------------------------------------------------
// | Copyright (c) 2018-2019 http://www.azthink.top All rights reserved.
// +----------------------------------------------------------------------
// | Author 李忠<azthink@qq.com>
// +----------------------------------------------------------------------
namespace app\admin\controller;

use app\admin\model\Log as LogModel;

/**
 * 行为日志控制器
 *
 * @author 李忠<azthink@qq.com>
 * @createAt 2018-09-02 15:32:30
 *
 */
class Log extends Admin {

    /**
     * 列表页面
     */
    public function index($module = 'admin', $model = null, $record_id = null, $remark = null) {

        // 数据列表
        $data_list = LogModel::lists($module, $model, null, $record_id, $remark);
        $this->assign('data_list', $data_list);
        $this->assign('pager', $data_list->render());

        $this->assign('module_list', config('module_list'));

        $this->assign('module', $module);
        $this->assign('model', $model);
        $this->assign('record_id', $record_id);
        $this->assign('remark', $remark);
        $this->setMeta('行为日志管理');
        return $this->fetch();
    }

    public function delete($id) {
        if (LogModel::state($id, -1)) {
            $this->log($id, '删除行为日志成功');
            $this->success('删除行为日志成功');
        } else {
            $this->error('删除行为日志失败');
        }
    }
}